Import('*')

env = env.Clone()

env.Prepend(CPPPATH = [
    '#src',
    '#src/mapi',
    '#src/mesa',
    Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
    Dir('../../../mapi/glapi'), # src/mapi/glapi build path
    Dir('../../../mapi/glapi/gen'), # src/mapi/glapi build path
])

env.Prepend(LIBS = [
    mesautil,
    glapi,
    compiler,
    mesa,
    spirv,
    nir,
    glsl,
])

sources = [
    'osmesa.c',
]

if env['platform'] == 'windows':
    env.AppendUnique(CPPDEFINES = [
        '_GDI32_', # prevent wgl* being declared __declspec(dllimport)
        'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
        '_GLAPI_NO_EXPORTS', # prevent _glapi_* from being declared __declspec(dllimport)
    ])

    sources += ['osmesa.def']

osmesa = env.SharedLibrary(
    target ='osmesa',
    source = sources,
)

env.Alias('osmesa', osmesa)
